package cn.gwm.flink.streaming.dwm.charge.model;

import lombok.Getter;

/**
 * @Author: liangguang
 * @Date: 2022/11/09
 * @Description: 充电状态
 */
@Getter
public enum ChargeStateEnum {

    UNKNOWN("-999", "unknown", "未知，不做处理也不下发"),
    OTHER("-9", "other", "其它"),

    CONNECT("0", "connect", "仅用于判断插枪连接"),
    // 物理断开
    END("6", "break", "充电结束,拔枪"),
    // 插枪中的状态
    ERROR("9", "error", "连接出错"),
    LOGIC_BREAK("8", "logic_break", "逻辑断开"),
    FAULT("7", "fault", "发生故障"),
    CHARGING("2", "charging", "正在充电"),
    FULLY("3", "fully", "充满电"),
    UNABLE("4", "unable", "充不进电"),
    SUSPEND("5", "suspend", "充电中断"),
    WAIT("1", "waiting", "待充电,等候充电"),
    DELAY("10", "delay", "延迟充电"),
    PREHEAT("11", "preheat", "充电预热"),
    CHARGING_HEATING("12", "chargingHeating", "充电且加热"),
    ;

    /**
     * 显示 编码
     */
    private String code;
    /**
     * 状态
     */
    private String state;
    /**
     * 描述
     */
    private String desc;

    ChargeStateEnum(String code, String state, String desc) {
        this.code = code;
        this.state = state;
        this.desc = desc;
    }

    /**
     * 根据类型的名称，返回类型的枚举实例。
     *
     * @param key 类型名称
     */
    public static ChargeStateEnum fromKey(String key) {
        for (ChargeStateEnum type : ChargeStateEnum.values()) {
            if (type.getCode().equals(key)) {
                return type;
            }
        }
        return null;
    }


}
